home *** CD-ROM | disk | FTP | other *** search
- _LINKING USER INFTERFACE AND DATABASE OBJECTS_
- by Eng-Lee Kwang and Christopher Rosebrugh
-
- EXAMPLE 1:
-
- (a)
-
- /* message template description */
- %func_template bool UI_DO_SOMETHING_M (
- obj_id /* IN: object pointer */
- );
-
- /* Object class message description mapping. It is NOT necessary to declare
- * parameters to message since they are already defined in template. */
- %function[UI_DO_SOMETHING_M] ui_Bag_do_something;
-
- --------------------------------------------------------------------------
- (b)
-
- /* These macros are used by the UI framework to pass messages to particular
- * objects without requiring explicit knowledge of the object classes.
- * The typedef and macros are AUTOMATICALLY generated from the message
- * template description. These macros, etc. are only used by framework. */
- #define UI_DO_SOMETHING_M_ID 1
- typedef void (*UI_DO_SOMETHING_M_fn_t)( obj_id );
- #define UI_DO_SOMETHING_M(_ftbl) (*(UI_DO_SOMETHING_M_fn_t)_ftbl[UI_DO_SOMETHING_M_ID])
-
- /* Messages are implemented as re-directed MACRO'ed functions through function
- * table. This typedef and define is AUTOMATICALLY generated from a high-level
- * message description. */
- typedef void (*ui_Bag_do_something_fn_t)( obj_id );
- #define ui_Bag_do_something (*(ui_Bag_do_something_fn_t)bag_ftbl[1])
-
- /* Message function table for object class Bag. This table is AUTOMATICALLY
- * generated from the high-level message description. */
- void *bag_ftbl[19] = {
- (void *)...,
- (void *)_ui_Bag_do_something,
- ...
- };
-
-
- EXAMPLE 2:
-
- (a)
-
- void _ui_Bag_do_something(
- ui_Bag_t *bag /* corresponds to an obj_id */
- )
- {
- ....
- }
-
-
- (b)
-
- /* Implementation of messaging mechanism for sending message DO_SOMETHING */
- bool ui_do_something(
- obj_id id,
- ...
- )
- {
- void **ftbl;
-
- /* look for message function table associated with the object ID. */
- ftbl = __find_object_ftbl(id);
- if (ftbl && &UI_DO_SOMETHING_M(ftbl)) {
- /* If function table exists for the object -> known object type
- * and message DO_SOMETHING is defined, pass the message to the
- * object (call the function!!) */
- return UI_DO_SOMETHING_M(ftbl)(id, ...);
- }
- return FALSE;
- }
-
-
-
- EXAMPLE 3:
-
- db_handle = db_Int16_new(123);
-
- viewer_1 = ui_Num_new(...);
-
- viewer_2 = ui_Gauge_new(...);
-
- ui_attach_data(viewer_1, db_handle);
-
- ui_attach_data(viewer_2, db_handle);
-
-
-
-